<template>
  <div class="sidebar">
    <el-menu :default-openeds="['4']" router :default-active="pathURL">
      <my-menu :menu="menuList"></my-menu>
    </el-menu>
  </div>
</template>

<script setup lang="ts">
//@ts-ignore
import myMenu from "./myMenu.vue"
import { useRoute } from "vue-router"
//@ts-ignore
import { useUserStore } from "@/store/useUserStore"
//@ts-ignore
import { storeToRefs } from "pinia"
import { computed } from "vue"

// 管理员 id 676e0515458a9b974496d1b9
const route = useRoute()
// 在进入页面
// 获取当前路由的path 作为 default-active
// useRouter 返回的是整个路由对象 router.push()
// useRoute 返回的是当前路的对象
const store = useUserStore()
const { menuList } = storeToRefs(store)


//浏览器刷新了也有高亮
const pathURL = computed(() => {
  if (route.meta.root) {
    return route.meta.root
  } else {
    return route.path
  }
})

</script>

<style></style>
